Skip to content

Conversation

@guoci
Copy link
Contributor

@guoci guoci commented Nov 2, 2025

@guoci guoci marked this pull request as ready for review November 2, 2025 22:24
Copy link
Contributor

@cmaloney cmaloney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good improvement as is, localize and delocalize are both documented functions in the module.

https://docs.python.org/3/library/locale.html#locale.delocalize
https://docs.python.org/3/library/locale.html#locale.localize

@guoci
Copy link
Contributor Author

guoci commented Nov 3, 2025

I think you want the test to be in a separate PR, I will revert the "add test" commit.

@cmaloney
Copy link
Contributor

cmaloney commented Nov 3, 2025

I hadn't realized how long the list of entries expected to be left out was for this module... I'm planning to propose a more general that that covers every stdlib module which uses __all__ rather than per-module ones so okay to me adding no test here.

@cmaloney
Copy link
Contributor

cmaloney commented Nov 4, 2025

cc: @malemburg (Experts index for locale)

@malemburg
Copy link
Member

malemburg commented Nov 4, 2025

These API are available in the locale module, but not listed in __all__:

['ABDAY_1', 'ABDAY_2', 'ABDAY_3', 'ABDAY_4', 'ABDAY_5', 'ABDAY_6', 'ABDAY_7', 'ABMON_1', 'ABMON_10', 'ABMON_11', 'ABMON_12', 'ABMON_2', 'ABMON_3', 'ABMON_4', 'ABMON_5', 'ABMON_6', 'ABMON_7', 'ABMON_8', 'ABMON_9', 'ALT_DIGITS', 'AM_STR', 'CODESET', 'CRNCYSTR', 'DAY_1', 'DAY_2', 'DAY_3', 'DAY_4', 'DAY_5', 'DAY_6', 'DAY_7', 'D_FMT', 'D_T_FMT', 'ERA', 'ERA_D_FMT', 'ERA_D_T_FMT', 'ERA_T_FMT', 'MON_1', 'MON_10', 'MON_11', 'MON_12', 'MON_2', 'MON_3', 'MON_4', 'MON_5', 'MON_6', 'MON_7', 'MON_8', 'MON_9', 'NOEXPR', 'PM_STR', 'RADIXCHAR', 'THOUSEP', 'T_FMT', 'T_FMT_AMPM', 'YESEXPR', 'bind_textdomain_codeset', 'bindtextdomain', 'dcgettext', 'delocalize', 'dgettext', 'encodings', 'functools', 'gettext', 'locale_alias', 'locale_encoding_alias', 'localize', 'nl_langinfo', 're', 'sys', 'textdomain', 'windows_locale']

(there may be more - I currently only have access to Python 3.12)

Out of these I found these to be undocumented / only used internally:

  • AM_STR - appears to be a documentation bug, this is for nl_langinfo()
  • PM_STR - appears to be a documentation bug, this is for nl_langinfo()
  • encodings - imported package
  • functools - imported package
  • locale_alias - this is a documentation bug, since the table is actually being used outside the module
  • locale_encoding_alias - documentation bug, same as above
  • re- imported module
  • sys - imported module
  • windows_locale - documentation bug, same as above

@malemburg
Copy link
Member

malemburg commented Nov 4, 2025

Here's a quick script to check these things:

#!/usr/bin/env python3
import locale
import types

public = {name for name in dir(locale) if not name.startswith('_')}
public_no_modules = public - {
    name
    for name in public if isinstance(getattr(locale, name), types.ModuleType)}
missing = sorted(public_no_modules - set(locale.__all__))
print (f'These attributes are missing from locale.__all__: {missing!r}')

@guoci
Copy link
Contributor Author

guoci commented Nov 5, 2025

Does this PR need any more modification?

@malemburg
Copy link
Member

Does this PR need any more modification?

It would be good to add the missing attributes to __all__ 🙂 And the test mentioned in the review is missing as well.

@bedevere-app
Copy link

bedevere-app bot commented Nov 9, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@guoci
Copy link
Contributor Author

guoci commented Nov 9, 2025

I have made the requested changes; please review again

@bedevere-app
Copy link

bedevere-app bot commented Nov 9, 2025

Thanks for making the requested changes!

@malemburg: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from malemburg November 9, 2025 16:23
@guoci
Copy link
Contributor Author

guoci commented Nov 14, 2025

@malemburg is that ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants